package com.dha.caodangcongnghe;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;

import com.dha.asynctask.SinhVienXemDiemAsyncTask;
import com.dha.status.NetworkStatus;
import com.dha.ultility.QuangCao;
import com.dha.variable.ThongTinTaiKhoan;
import com.dha.variable.XemDiemVariable;

public class SinhVienXemDiem extends ActionBarActivity {
	private TextView tvTenSinhVien, tvMaSinhVien;
	private NetworkStatus networkStatus;
	
//	private QuangCao quangCao;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_xemdiem_daydu);

//		quangCao = new QuangCao(this, SinhVienXemDiem.this);
		
		tvTenSinhVien = (TextView) findViewById(R.id.tv_tenSV_Diem);
		tvMaSinhVien = (TextView) findViewById(R.id.tv_MaSV_Diem);

		tvMaSinhVien.setText(ThongTinTaiKhoan.maTaiKhoan);
		tvTenSinhVien.setText(ThongTinTaiKhoan.hoTen);
		networkStatus = new NetworkStatus(getBaseContext());

		SinhVienXemDiemAsyncTask asyncTask = new SinhVienXemDiemAsyncTask(SinhVienXemDiem.this,
				ThongTinTaiKhoan.maTaiKhoan,
				XemDiemVariable.METHOD_NAME_XEMDIEMHOCKYHIENTAI);
		asyncTask.execute();

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.menu_xemdiem, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		// case R.id.mn_XemDiem_XemTheoHocKy:
		// Intent intentDaSachHocKy = new Intent("DanhSachHocKy");
		// intentDaSachHocKy.putExtra("MaSo", ThongTinTaiKhoan.maTaiKhoan);
		// startActivity(intentDaSachHocKy);
		// break;
		case R.id.mn_XemDiem_XemTheoTongKet:
			if (networkStatus.isConnected()) {
				Intent itentTongKet = new Intent("XemDiemTongKet");
				startActivity(itentTongKet);
			} else {
				Intent intentLoi = new Intent("SuCoVeKetNoiMang");
				startActivity(intentLoi);
			}
			break;
		case R.id.mn_XemDiem_XemTheoTatCaHocKy:
			if (networkStatus.isConnected()) {
				SinhVienXemDiemAsyncTask asyncTask = new SinhVienXemDiemAsyncTask(SinhVienXemDiem.this,
						ThongTinTaiKhoan.maTaiKhoan,
						XemDiemVariable.METHOD_NAME_XEMDIEMTATCAHOCKY);
				asyncTask.execute();
			} else {
				Intent intentLoi = new Intent("SuCoVeKetNoiMang");
				startActivity(intentLoi);
			}
			break;
		}
		return super.onOptionsItemSelected(item);
	}

}
